2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
19 struct MapAxes: View {
22 let lineWidth: CGFloat
25 let stageHeight = CGFloat(100.0)
26 let padding = CGFloat(5.0)
29 ZStack(alignment: .topLeading) {
33 path.move(to: CGPoint(x: 0, y: 0))
34 path.addLine(to: CGPoint(x: 0, y: mapSize.height))
35 path.addLine(to: CGPoint(x: mapSize.width, y: mapSize.height))
36 path.move(to: CGPoint(x: mapSize.width, y: mapSize.height))
38 }.stroke(Color.map.axisColor, lineWidth: lineWidth * 2)
41 Text("Visible").font(.theme.axisLabel).foregroundColor(.map.labelColor).rotationEffect(
44 .offset(CGSize(width: -35.0, height: 0.0))
45 Text("Invisible").font(.theme.axisLabel).foregroundColor(.map.labelColor).rotationEffect(
48 .offset(CGSize(width: -40.0, height: mapSize.height - 20))
53 .font(.theme.axisLabel)
54 .foregroundColor(.map.labelColor)
55 .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading)
56 .offset(CGSize(width: 0.0, height: -stageHeight / 4.0))
57 Text("Industrialised")
58 .font(.theme.axisLabel)
59 .foregroundColor(.map.labelColor)
60 .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading)
61 .offset(CGSize(width: mapSize.width - 100.0, height: -stageHeight / 4.0))
64 .font(.theme.axisLabel)
65 .foregroundColor(.map.labelColor)
66 .frame(width: w(stages[0]), height: stageHeight, alignment: .topLeading)
67 .offset(CGSize(width: 0.0, height: mapSize.height + padding))
70 .font(.theme.axisLabel)
71 .foregroundColor(.map.labelColor)
72 .frame(width: w(stages[1]) - w(stages[0]), height: stageHeight, alignment: .topLeading)
73 .offset(CGSize(width: w(stages[0]), height: mapSize.height + padding))
76 .font(.theme.axisLabel)
77 .foregroundColor(.map.labelColor)
78 .frame(width: w(stages[2]) - w(stages[1]), height: stageHeight, alignment: .topLeading)
79 .offset(CGSize(width: w(stages[1]), height: mapSize.height + padding))
82 .font(.theme.axisLabel)
83 .foregroundColor(.map.labelColor)
84 .frame(width: mapSize.width - w(stages[2]), height: stageHeight, alignment: .topLeading)
85 .offset(CGSize(width: w(stages[2]), height: mapSize.height + padding))
89 func w(_ dimension: CGFloat) -> CGFloat {
90 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
96 mapSize: CGSize(width: 200.0, height: 200.0), lineWidth: CGFloat(1.0),
97 evolution: Stage.stages(.general), stages: [25.0, 50.0, 75.0]